package com.chenfan.mcn.service.impl;

import com.chenfan.mcn.model.PlatformDiscountRange;
import com.chenfan.mcn.dao.PlatformDiscountRangeMapper;
import com.chenfan.mcn.service.PlatformDiscountRangeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * <p>
 * 优惠价格梯度 服务实现类
 * </p>
 *
 * @author lizhejin
 * @since 2021-01-07
 */
@Service
public class PlatformDiscountRangeServiceImpl extends ServiceImpl<PlatformDiscountRangeMapper, PlatformDiscountRange> implements PlatformDiscountRangeService {

    @Override
    public BigDecimal getMatchedRate(Long discountId, String platformId, BigDecimal businessYearAmount) {
        return baseMapper.getMatchedRate(discountId, platformId, businessYearAmount);
    }

    /**
     * 通过累计金额，匹配优惠梯度，得到的对应返点比例。
     *
     * @param discountId        {@link Long}
     * @param accumulatedAmount {@link BigDecimal}
     * @return {@link BigDecimal}
     */
    @Override
    public BigDecimal getRebateRatio(Long discountId, BigDecimal accumulatedAmount) {
        return this.baseMapper.getRebateRatio(discountId, accumulatedAmount);
    }
}
